<%@page import="steed.util.system.JspMethod"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="/WEB-INF/jsp/hadmin/commonHeader.jsp"%>
<script>
	var iframes = [];
</script>
<link href="./h/css/plugins/jsTree/style.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./h/css/icon/iconfont.css">
<style>
.jstree-open>.jstree-anchor>.fa-folder:before {
	content: "\f07c";
}

.jstree-default .jstree-icon.none {
	width: 0;
}

#jstree_demo_div a {
	display: inline;
	padding-left: 0;
	font-size: 12px;
}
#top-search{display:inline-block; position:relative;border:1px solid #ddd;height:42px;margin:12px 0 5px 0;background:rgba(255,255,255,1)}
.sowtypeplaceholder,.finishtypeplaceholder{
	display:none;
	position:absolute; top:24px; left:75px; z-index:2018; color:#999;cursor:pointer;
}
.finishdateplaceholder{
	display:none;
	position:absolute; top:12px; left:72px; z-index:2018; color:#999;cursor:pointer;
}
.searchstatebox{
	cursor:pointer;color:#1ab394;
}
.finishdatebox{
	border: 1px solid #ddd;
    height: 42px;
    width: 80px;
}
.searchbtnstyle{
	position:absolute; left: 564px;top: 12px;height: 42px;border:0;border-radius:3px;
	width: 80px;
    color: #1ab394;
    font-size: 27px;
}
._finishdatebtn{height:42px;position: relative;
    left: -3px;}
</style>
</head>

<body class="fixed-sidebar full-height-layout gray-bg"
	style="overflow: hidden">
	<div id="wrapper">
		<!--左侧导航开始-->
		<nav class="navbar-default navbar-static-side" role="navigation">
			<div class="nav-close">
				<i class="fa fa-times-circle"></i>
			</div>
			<div class="sidebar-collapse">
				<ul class="nav" id="side-menu">
					<li class="nav-header" style="padding: 14px 25px;">
						<div class="profile-element">
							<div style="text-align:center;">
								<img alt="image" src="./images/logosm.png" />
							</div>
							<div class="dropdown removeOpen">
								<a data-toggle="dropdown" class="dropdown-toggle" href="#">
									<span class="clear"> <span class="block m-t-xs">
										<span >
											<!-- 用户存在姓名即显示姓名，否则显示用户名 --> 
											
											<c:choose>
												<c:when test='${empty sessionScope.admin.name }'>
													用户名：
													${sessionScope.admin.nickName }
												</c:when>
												<c:otherwise>
													姓名：
													${sessionScope.admin.name }
												</c:otherwise>
											</c:choose>
										</span> 
										<b title="操作" class="caret" style="float: right; right: 55px; bottom: 7px; position: absolute"></b></span>
									</span>
								</a>
								<ul class="dropdown-menu animated fadeInRight m-t-xs">
									<li><a class="J_menuItem" onclick="personalData();"
										href="./hadmin/system/setting/changePassword/index.act">修改密码</a>
									</li>
									<li><a class="J_menuItem" onclick="personalData();"
										href="./hadmin/system/setting/userCenter/index.act">个人资料</a></li>
									<li><a class="J_menuItem" onclick="personalData();"
										href="./hadmin/system/setting/changePhone/index.act">修改手机号</a>
									</li>
									<li class="divider"></li>
									<li><a href="./hadmin/logout.act">安全退出</a></li>
								</ul>
							</div>
							<span title="<c:forEach items="${roleSet}" var="item" varStatus="status"><c:if test="${status.index != 0 }">,</c:if>${item.name}</c:forEach>" class="text-muted text-xs block">
								角色：
								<c:forEach items="${admin.roleSet}" var="item" varStatus="status">
									<c:if test="${status.index != 0 }">,</c:if>
									${item.name}
								</c:forEach>
							</span>
						</div>
						<div class="logo-element">H+</div>
					</li>
					<%=JspMethod.outHadminMenu((List) session.getAttribute("menuList"))%>
				</ul>
			</div>
		</nav>
		<!--左侧导航结束-->
		<!--右侧部分开始-->
		<div id="page-wrapper" class="gray-bg dashbard-1">
			<div class="row border-bottom">
				<nav class="navbar navbar-static-top" role="navigation"
					style="margin-bottom: 0">
					<div class="navbar-header">
						<a class="navbar-minimalize minimalize-styl-2 btn btn-primary "><i
							class="fa fa-bars"></i> </a>
						z
					</div>
					<ul class="nav navbar-top-links navbar-right">
						<li id="pigPenInputDiv" class="dropdown">
							<div style="height: 47px;">
								<input id="pigPenInput" placeholder="猪场/组织选择"
									class="form-control dropdown-toggle count-info"
									name="top-search" id="top-search" type="text">
							</div>
							<div class="dropdown-menu dropdown-messages">
								<div id="event_result"></div>
								<div class="sidebar-title">
									<div id="jstree_demo_div"></div>
								</div>
							</div>
						</li>
						<!-- <li class="dropdown"><a class="dropdown-toggle count-info"
							data-toggle="dropdown" href="#"> <i class="fa fa-envelope"></i>
								<span class="label label-warning">16</span>
						</a>
							<ul class="dropdown-menu dropdown-messages">
								<li class="m-t-xs">
									<div class="dropdown-messages-box">
										<a href="profile.html" class="pull-left">
                                            <img alt="image" class="img-circle" src="img/a7.jpg">
                                        </a>
										<div class="media-body">
											<small class="pull-right">46小时前</small> <strong>小四</strong>
											这个在日本投降书上签字的军官，建国后一定是个不小的干部吧？ <br> <small
												class="text-muted">3天前 2016.11.8</small>
										</div>
									</div>
								</li>
								<li class="divider"></li>
								<li>
									<div class="dropdown-messages-box">
										<a href="profile.html" class="pull-left">
                                            <img alt="image" class="img-circle" src="img/a4.jpg">
                                        </a>
										<div class="media-body ">
											<small class="pull-right text-navy">25小时前</small> <strong>国民岳父</strong>
											如何看待“男子不满自己爱犬被称为狗，刺伤路人”？——这人比犬还凶 <br> <small
												class="text-muted">昨天</small>
										</div>
									</div>
								</li>
								<li class="divider"></li>
								<li>
									<div class="text-center link-block">
										<a class="J_menuItem" href="mailbox.html"> <i
											class="fa fa-envelope"></i> <strong> 查看所有消息</strong>
										</a>
									</div>
								</li>
							</ul></li>-->
						 <!-- <li class="dropdown"><a class="dropdown-toggle count-info"
							data-toggle="dropdown" href="#"> <i class="fa fa-bell"></i> <span
								class="label label-primary">8</span>
						</a>
							<ul class="dropdown-menu dropdown-alerts">
								<li><a href="mailbox.html">
										<div>
											<i class="fa fa-envelope fa-fw"></i> 您有16条未读消息 <span
												class="pull-right text-muted small">4分钟前</span>
										</div>
								</a></li>
								<li class="divider"></li>
								<li><a href="profile.html">
										<div>
											<i class="fa fa-qq fa-fw"></i> 3条新回复 <span
												class="pull-right text-muted small">12分钟钱</span>
										</div>
								</a></li>
								<li class="divider"></li>
								<li>
									<div class="text-center link-block">
										<a class="J_menuItem" href="notifications.html"> <strong>查看所有
										</strong> <i class="fa fa-angle-right"></i>
										</a>
									</div>
								</li>
							</ul></li> -->
						<!-- <li class="hidden-xs">
                            <a href="index_v1.html" class="J_menuItem" data-index="0"><i class="fa fa-cart-arrow-down"></i> 购买</a>
                        </li> -->
						<li class="dropdown hidden-xs"><a
							class="right-sidebar-toggle" aria-expanded="false"> <i
								class="fa fa-tasks"></i> 主题
						</a></li>
					</ul>
				</nav>
			</div>
			<div class="row content-tabs" style="height:36px;">
				<button class="roll-nav roll-left J_tabLeft" style="height:34px; line-height:34px;">
					<i class="fa fa-backward"></i>
				</button>
				<nav class="page-tabs J_menuTabs" style="height:34px;">
					<div class="page-tabs-content">
						<a href="javascript:;" class="active J_menuTab"
							data-id="./hadmin/home.act">首页</a>
					</div>
				</nav>
				<button class="roll-nav roll-right J_tabRight" style="height:34px;">
					<i class="fa fa-forward"></i>
				</button>
				<div class="btn-group roll-nav roll-right" style="height:34px;">
					<button class="dropdown J_tabClose" data-toggle="dropdown" style="height:34px;">
						关闭操作<span class="caret"></span>

					</button>
					<ul role="menu" class="dropdown-menu dropdown-menu-right">
						<li class="J_tabShowActive"><a>定位当前选项卡</a></li>
						<li class="divider"></li>
						<li class="J_tabCloseAll"><a>关闭全部选项卡</a></li>
						<li class="J_tabCloseOther"><a>关闭其他选项卡</a></li>
					</ul>
				</div>
				<a href="./hadmin/logout.act" class="roll-nav roll-right J_tabExit" style="height:34px;"><i
					class="fa fa fa-sign-out"></i> 退出</a>
			</div>
			<div class="row J_mainContent" id="content-main">
				<iframe class="J_iframe" name="iframe0" width="100%" height="100%"
					src="./hadmin/home.act" frameborder="0" data-id="./hadmin/home.act"
					seamless></iframe>
			</div>
			<div class="footer">
				<div style="text-align: center;">
					Copyright © 2015-2020 Winland Technologies, Inc. All Rights Reserved
			| 客服热线：400-777-2180 | 粤ICP备10099853号-4
				</div>
			</div>
		</div>
		<!--右侧部分结束-->
		<!--右侧边栏开始-->
		<div id="right-sidebar">
			<div class="sidebar-container">

				<ul class="nav nav-tabs navs-3">

					<li class="active"><a data-toggle="tab" href="#tab-1"> <i
							class="fa fa-gear"></i> 主题
					</a></li>
					<!-- <li class=""><a data-toggle="tab" href="#tab-2"> 通知 </a></li>
					<li><a data-toggle="tab" href="#tab-3"> 项目进度 </a></li> -->
				</ul>

				<div class="tab-content">
					<div id="tab-1" class="tab-pane active">
						<div class="sidebar-title">
							<h3>
								<i class="fa fa-comments-o"></i> 主题设置
							</h3>
							<small><i class="fa fa-tim"></i>
								你可以从这里选择和预览主题的布局和样式，这些设置会被保存在本地，下次打开的时候会直接应用这些设置。</small>
						</div>
						<div class="skin-setttings">
							<div class="title">主题设置</div>
							<div class="setings-item">
								<span>收起左侧菜单</span>
								<div class="switch">
									<div class="onoffswitch">
										<input type="checkbox" name="collapsemenu"
											class="onoffswitch-checkbox" id="collapsemenu"> <label
											class="onoffswitch-label" for="collapsemenu"> <span
											class="onoffswitch-inner"></span> <span
											class="onoffswitch-switch"></span>
										</label>
									</div>
								</div>
							</div>
							<div class="setings-item">
								<span>固定顶部</span>

								<div class="switch">
									<div class="onoffswitch">
										<input type="checkbox" name="fixednavbar"
											class="onoffswitch-checkbox" id="fixednavbar"> <label
											class="onoffswitch-label" for="fixednavbar"> <span
											class="onoffswitch-inner"></span> <span
											class="onoffswitch-switch"></span>
										</label>
									</div>
								</div>
							</div>
							<div class="setings-item">
								<span> 固定宽度 </span>

								<div class="switch">
									<div class="onoffswitch">
										<input type="checkbox" name="boxedlayout"
											class="onoffswitch-checkbox" id="boxedlayout"> <label
											class="onoffswitch-label" for="boxedlayout"> <span
											class="onoffswitch-inner"></span> <span
											class="onoffswitch-switch"></span>
										</label>
									</div>
								</div>
							</div>
							<div class="title">皮肤选择</div>
							<div class="setings-item default-skin nb">
								<span class="skin-name "> <a href="#" class="s-skin-0">
										默认皮肤 </a>
								</span>
							</div>
							<div class="setings-item blue-skin nb">
								<span class="skin-name "> <a href="#" class="s-skin-1">
										蓝色主题 </a>
								</span>
							</div>
							<div class="setings-item yellow-skin nb">
								<span class="skin-name "> <a href="#" class="s-skin-3">
										黄色/紫色主题 </a>
								</span>
							</div>
						</div>
					</div>
					<div id="tab-2" class="tab-pane">

						<div class="sidebar-title">
							<h3>
								<i class="fa fa-comments-o"></i> 最新通知
							</h3>
							<small><i class="fa fa-tim"></i> 您当前有10条未读信息</small>
						</div>

						<div>

							<div class="sidebar-message">
								<a href="#">
									<div class="pull-left text-center">
										<!-- <img alt="image" class="img-circle message-avatar" src="img/a1.jpg"> -->

										<div class="m-t-xs">
											<i class="fa fa-star text-warning"></i> <i
												class="fa fa-star text-warning"></i>
										</div>
									</div>
									<div class="media-body">

										据天津日报报道：瑞海公司董事长于学伟，副董事长董社轩等10人在13日上午已被控制。 <br> <small
											class="text-muted">今天 4:21</small>
									</div>
								</a>
							</div>
							<div class="sidebar-message">
								<a href="#"> <!-- <div class="pull-left text-center">
                                        <img alt="image" class="img-circle message-avatar" src="img/a2.jpg">
                                    </div> -->
									<div class="media-body">
										HCY48之音乐大魔王会员专属皮肤已上线，快来一键换装拥有他，宣告你对华晨宇的爱吧！ <br> <small
											class="text-muted">昨天 2:45</small>
									</div>
								</a>
							</div>
							<div class="sidebar-message">
								<a href="#">
									<div class="pull-left text-center">
										<!--  <img alt="image" class="img-circle message-avatar" src="img/a3.jpg"> -->

										<div class="m-t-xs">
											<i class="fa fa-star text-warning"></i> <i
												class="fa fa-star text-warning"></i> <i
												class="fa fa-star text-warning"></i>
										</div>
									</div>
									<div class="media-body">
										写的好！与您分享 <br> <small class="text-muted">昨天 1:10</small>
									</div>
								</a>
							</div>
							<div class="sidebar-message">
								<a href="#"> <!-- <div class="pull-left text-center">
                                        <img alt="image" class="img-circle message-avatar" src="img/a4.jpg">
                                    </div> -->

									<div class="media-body">
										国外极限小子的炼成！这还是亲生的吗！！ <br> <small class="text-muted">昨天
											8:37</small>
									</div>
								</a>
							</div>
							<div class="sidebar-message">
								<a href="#"> <!-- <div class="pull-left text-center">
                                        <img alt="image" class="img-circle message-avatar" src="img/a8.jpg">
                                    </div> -->
									<div class="media-body">

										一只流浪狗被收留后，为了减轻主人的负担，坚持自己觅食，甚至......有些东西，可能她比我们更懂。 <br> <small
											class="text-muted">今天 4:21</small>
									</div>
								</a>
							</div>
							<div class="sidebar-message">
								<a href="#"> <!-- <div class="pull-left text-center">
                                        <img alt="image" class="img-circle message-avatar" src="img/a7.jpg">
                                    </div> -->
									<div class="media-body">
										这哥们的新视频又来了，创意杠杠滴，帅炸了！ <br> <small class="text-muted">昨天
											2:45</small>
									</div>
								</a>
							</div>
							<div class="sidebar-message">
								<a href="#">
									<div class="pull-left text-center">
										<!-- <img alt="image" class="img-circle message-avatar" src="img/a3.jpg">
 -->
										<div class="m-t-xs">
											<i class="fa fa-star text-warning"></i> <i
												class="fa fa-star text-warning"></i> <i
												class="fa fa-star text-warning"></i>
										</div>
									</div>
									<div class="media-body">
										最近在补追此剧，特别喜欢这段表白。 <br> <small class="text-muted">昨天
											1:10</small>
									</div>
								</a>
							</div>
							<div class="sidebar-message">
								<a href="#"> <!-- <div class="pull-left text-center">
                                        <img alt="image" class="img-circle message-avatar" src="img/a4.jpg">
                                    </div> -->
									<div class="media-body">
										我发起了一个投票 【你认为下午大盘会翻红吗？】 <br> <small class="text-muted">星期一
											8:37</small>
									</div>
								</a>
							</div>
						</div>

					</div>
					<div id="tab-3" class="tab-pane">

						<div class="sidebar-title">
							<h3>
								<i class="fa fa-cube"></i> 最新任务
							</h3>
							<small><i class="fa fa-tim"></i> 您当前有14个任务，10个已完成</small>
						</div>
					</div>
				</div>

			</div>
		</div>
		<!--右侧边栏结束-->
		<!--mini聊天窗口开始 暂时不需要聊天窗口-->
		<div style="display: none;"
			class="small-chat-box fadeInRight animated">

			<div class="heading" draggable="true">
				<small class="chat-date pull-right"> 2015.9.1 </small> 与 Beau-zihan
				聊天中
			</div>

			<div class="content">

				<div class="left">
					<div class="author-name">
						Beau-zihan <small class="chat-date"> 10:02 </small>
					</div>
					<div class="chat-message active">你好</div>

				</div>
				<div class="right">
					<div class="author-name">
						游客 <small class="chat-date"> 11:24 </small>
					</div>
					<div class="chat-message">你好，请问H+有帮助文档吗？</div>
				</div>
				<div class="left">
					<div class="author-name">
						Beau-zihan <small class="chat-date"> 08:45 </small>
					</div>
					<div class="chat-message active">有，购买的H+源码包中有帮助文档，位于docs文件夹下
					</div>
				</div>
				<div class="right">
					<div class="author-name">
						游客 <small class="chat-date"> 11:24 </small>
					</div>
					<div class="chat-message">那除了帮助文档还提供什么样的服务？</div>
				</div>
				<div class="left">
					<div class="author-name">
						Beau-zihan <small class="chat-date"> 08:45 </small>
					</div>
					<div class="chat-message active">
						1.所有源码(未压缩、带注释版本)； <br> 2.说明文档； <br> 3.终身免费升级服务； <br>
						4.必要的技术支持； <br> 5.付费二次开发服务； <br> 6.授权许可； <br> …… <br>
					</div>
				</div>
			</div>
			<div class="form-chat">
				<div class="input-group input-group-sm">
					<input type="text" class="form-control"> <span
						class="input-group-btn">
						<button class="btn btn-primary" type="button">发送</button>
					</span>
				</div>
			</div>

		</div>
		<!-- 暂时不需要聊天窗口 -->
		<div style="display: none;" id="small-chat">
			<span class="badge badge-warning pull-right">5</span> <a
				class="open-small-chat"> <i class="fa fa-comments"></i>

			</a>
		</div>
		<!--mini聊天窗口结束-->
	</div>
	
	<!-- 全局js -->
	<script src="./h/js/plugins/metisMenu/jquery.metisMenu.js"></script>
	<script src="./h/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
	<script src="./h/js/plugins/layer/layer.min.js"></script>

	<!-- 自定义js -->
	<script src="./h/js/hplus.js?v=4.1.0"></script>
	<script type="text/javascript" src="./h/js/contabs.js"></script>

	<!-- 第三方插件 -->
	<script src="./h/js/plugins/pace/pace.min.js"></script>
	<!-- onclick跳转 -->
	<script type="text/javascript">
		function linkToPig(){
			var type = $("#top-search").attr("data-type");
			var paramStr = "";
 			if (type == 0) {
 				var param = $("#top-search").val();
 				var reg =/^[\u4E00-\u9FA5]+$/;
 				if(reg.test(param)){
 					alert("请输入正确的耳标号");
 					$("#top-search").val("");
 					return false;
 				}
				paramStr = "earNumber=" + param;
			}
			else if (type == 2) {
				var containsAntibiotic = $("#top-search").attr("data-val");
				if (containsAntibiotic == "YK") {
					paramStr = "containsAntibiotic=1";
				}
				else {
					paramStr = "containsAntibiotic=0";
				}
			}
			else if (type == 3) {
				var startAge = $("#top-search").attr("data-startdate");
				var endAge = $("#top-search").attr("data-enddate");
				var nowDate = new Date();
				var starDate = new Date(nowDate.getTime()-endAge*(1000*60*60*24));
				var endDate = new Date(nowDate.getTime()-startAge*(1000*60*60*24));
				var startParam = starDate.getFullYear()+"-"+(starDate.getMonth()+1)+"-"+starDate.getDate(); 
	    		var endParam = endDate.getFullYear()+"-"+(endDate.getMonth()+1)+"-"+endDate.getDate(); 
				
				paramStr = "birthday_min_1="+startParam + "&birthday_max_1=" + endParam;
				
			}
			parent.menuItem("./hadmin/business/commercialPig/commercialPig/index.act?" + paramStr,'猪只列表');
		} 
	</script>
	<!-- jsTree引用 -->
	<script src="./h/js/plugins/jsTree/jstree.min.js"></script>
	<!-- jsTree引用介绍 -->
	<script type="text/javascript">
	var change = false;
		function closeOtherTabsTest() {
			for ( var f in iframes) {
				if(typeof iframes[f].refresh == 'function'){
					iframes[f].refresh();
				}
			}
		}
		function personalData() {
			$('.removeOpen').removeClass("open");
		}

		$(function() {
			//查询耳标
			$("#top-search").change(function(){
				$("._searchinput").attr("placeholder","").attr("data-type",0)
			});
			//单击母猪状态
			$("._sowstatus").click(function(){
				$("._sowtype").show();
				$("._finishtype").hide();
				$("._finishdate").hide();
				$("._searchinput").attr("placeholder","").val("").attr("data-val","").attr("data-startdate","").attr("data-enddate","").attr("data-type",1);
			});
			//单击肥猪状态
			$("._finishstatus").click(function(){
				$("._sowtype").hide();
				$("._finishtype").show();
				$("._finishdate").hide();
				$("._searchinput").attr("placeholder","").val("").attr("data-val","").attr("data-startdate","").attr("data-enddate","").attr("data-type",2);
			});
			//单击肥猪日龄
			$("._finishdateitem").click(function(){
				$("._sowtype").hide();
				$("._finishtype").hide();
				$("._finishdate").show();
				$("._searchinput").attr("placeholder","").val("").attr("data-val","").attr("data-startdate","").attr("data-enddate","").attr("data-type",3);
			});
			//单击选项
			$("._typeclick>span").click(function(){
				var _val = $(this).attr('data-val');
				var _htmltmp = $(this).html();
				$("._sowtype").hide();
				$("._finishtype").hide();
				$("._finishdate").hide();
				var _html = _htmltmp.split("|")[0];
				$("._searchinput").val(_html).focus().attr("data-val",_val).attr("data-startdate","").attr("data-enddate","");
			});
			//单击肥猪日龄确定按钮
			$("._finishdatebtn").click(function(){
				var _start = $(".startfinishdate").val();
				var _end = $(".endfinishdate").val();
				var _html = _start+" 至 "+_end+"天";
				if(!_start || !_end){
					alert("请输入要查询的日龄区间");
					return false;
				}
				$("._sowtype").hide();
				$("._finishtype").hide();
				$("._finishdate").hide();
				$("._searchinput").val(_html).focus().attr("data-startdate",_start).attr("data-enddate",_end);
				return false;
			});
			
			var removeClass = false;
			$('#jstree_demo_div').on('select_node.jstree', function(e, data) {
				var organizationText = data.instance.get_node(data.selected[0]).text;
				var organizationId = data.instance.get_node(data.selected[0]).id;
				if (removeClass) {//防止get组织时进行组织设置
					$.ajax({
						type : "POST",
						//"toastMsg":true,//请求成功是否显示提示
						//global:false,
						//async:false,//设置是否同步
						"data" : {
							"organizationId" : organizationId
						},
						dataType : "json",
						url : "<st:getCurrentUrl lastUrl='setOrganization.act' />",
						onSuccess : function(json) {
							$('#pigPenInputDiv').removeClass("open");
							removeClass = true;
							closeOtherTabsTest();
						},
						onFail : function(){
							layer.msg('网络异常，设置组织失败，请刷新重试！！！');
						}
					});
				} else {
					removeClass = true;
				}
			}).on('changed.jstree', function(e, data) {
				//选中组织/猪场
				$('#pigPenInput').val(data.instance.get_node(data.selected[0]).text);
				//$('#pigPenInputDiv').removeClass("open");
			}).jstree({
				"plugins" : [ "search" ],
				'core' : {
					'multiple' : false,//设置只能单选
					'data' : function(obj, callback) {
						var jsonstr = "[]";
						var jsonarray;//= eval('('+jsonstr+')');
						$.ajax({
							type : "POST",
							//global:false,
							async : false,
							dateType : "json",
							url : "<st:getCurrentUrl lastUrl='getOrganization.act' />",
							onSuccess : function(json) {
								var x = JSON.stringify(json);
								jsonarray = json;
							},
							onFail : function(json) {
								layer.msg('网络异常，查询组织失败，请刷新重试！！！');
							}
						});

						//jsonarray.push(arr);
						//var organizationJson ="[{'text':'css2','id':'1','state':{'selected':true}},{'text':'Resources','state':{'opened':false},'children':[{'text':'css','children':[{'text':'animate.css','icon':'none'},{'text':'bootstrap.css','icon':'none'},{'text':'main.css','icon':'none'},{'text':'style.css','icon':'none'}],'state':{'opened':false}},{'text':'js','children':[{'text':'bootstrap.js','icon':'none'},{'text':'hplus.min.js','icon':'none'},{'text':'jquery.min.js','icon':'none'},{'text':'jsTree.min.js','icon':'none'},{'text':'custom.min.js','icon':'none'}],'state':{'opened':false}},{'text':'html','children':[{'text':'layout.html','icon':'none'},{'text':'navigation.html','icon':'none'},{'text':'navbar.html','icon':'none'},{'text':'footer.html','icon':'none'},{'text':'sidebar.html','icon':'none'}],'state':{'opened':false}}]},'Fonts','Images','Scripts','Templates',]";
						//console.log(jsonarray)
						callback.call(this, jsonarray);
					}
				}
			});

			var to = false;
			$('#pigPenInput').keyup(function() {
				if (to) {
					clearTimeout(to);
				}
				to = setTimeout(function() {
					var v = $('#pigPenInput').val();
					$('#jstree_demo_div').jstree(true).search(v);
				}, 250);
			});

			//猪场选择
			$('#pigPenInput').click(function(e) {
				removeClass = false;
				$('#pigPenInputDiv').addClass("open");
				$('#jstree_demo_div').jstree().refresh(true);
				stopPropagation(e);
			});
			document.onclick = function(e) {
				$('#pigPenInputDiv').removeClass("open");
			}

			//组织/猪场选择防止冒泡
			function stopPropagation(e) {
				if (e.stopPropagation)
					e.stopPropagation();
				else
					e.cancelBubble = true;
			}

			$('#jstree_demo_div').click(function(e) {
				stopPropagation(e);
			});
		});
	</script>
	<!-- 点击链接添加选项卡 -->
	<script type="text/javascript">
	function menuItem(dataUrl, menuName) {
		// 选项卡菜单已存在
		var url = dataUrl;
		if(dataUrl.indexOf('?') > -1){
			url = dataUrl.substring(0,dataUrl.indexOf('?'));
			dataUrl = dataUrl + "&1=1"+Math.random();
		}
		var flag = true;
		$('.J_menuTab').each(function() {
			if ($(this).data('id') == url) {
				if (true || !$(this).hasClass('active')) {
					$(this).addClass('active').siblings('.J_menuTab').removeClass('active');
					scrollToTab(this);
					// 显示tab对应的内容区
					$('.J_mainContent .J_iframe').each(function() {
						//alert($(this).data('id'));
						if ($(this).data('id') == url) {
							$(this).show().siblings('.J_iframe').hide();
							/* alert(dataUrl); */
							$(this).attr("src",dataUrl);
							return false;
						}
					});
				}
				flag = false;
				return false;
			}
		});
		if (flag) {
			// 选项卡菜单不存在
			var str = '<a href="javascript:;" class="active J_menuTab" data-id="' + url + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
			$('.J_menuTab').removeClass('active');
			var dataIndex = 10000000;
			// 添加选项卡对应的iframe
			var str1 = '<iframe class="J_iframe" name="iframe' + dataIndex++ + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + url
					+ '" seamless></iframe>';
			$('.J_mainContent').find('iframe.J_iframe').hide().parents('.J_mainContent').append(str1);

			//显示loading提示
			//            var loading = layer.load();
			//
			//            $('.J_mainContent iframe:visible').load(function () {
			//                //iframe加载完成后隐藏loading提示
			//                layer.close(loading);
			//            });
			// 添加选项卡
			$('.J_menuTabs .page-tabs-content').append(str);
			scrollToTab($('.J_menuTab.active'));
		}
	}
</script>
</body>

</html>
